package com.bubblegumproject.ogo.swing;

import com.bubblegumproject.ogo.action.AbstractFlow;

/**
 * A UIProcess is an ongoing process that encapsulates the flow logic for a {@link UIActivity}.
 *
 * @author Azubuko Obele (buko.obele@gmail.com)
 */
public class UIProcess<T extends UIActivity> extends AbstractFlow {

    /**
     * Every UIProcess is associated with a single UIActivity.
     */
    protected T activity;


    public T getActivity() {
        return activity;
    }

    public void setActivity(T activity) {
        this.activity = activity;
    }


    public void setFinished(boolean finished) {
        super.setFinished(finished);

        // By default, as soon as the UIProcess is finished we invoke UIActivity.stop() that notifies the parent that
        // the activity has stopped and performs all clean up
        if (finished) {
            activity.stop();
        }
    }
}
